fix(toxiproxy): add Toxiproxy container module - #1105
Merged
alexanderankin merged 2 commits intoAug 26, 2026
Merged
Conversation
Contributor
Author
|
Gentle nudge 🙂 @alexanderankin — this has been open for about a week and is ready whenever you (or another maintainer) have a moment to review or approve the CI run. Happy to address any feedback. Thanks! |
Lets you simulate bad network conditions - latency, limited bandwidth, dropped connections - against a service in integration tests. Toxiproxy already ships as a module for the Java, Go and .NET bindings, so this just catches Python up. The container exposes the HTTP control API and a range of proxy ports. create_proxy() puts a proxy in front of an upstream and add_toxic() adds the failures; it talks to the control API over urllib so there are no extra dependencies. Comes with an integration test, docs and an example.
JonnasFigueiredo
force-pushed
the
feature/toxiproxy-container
branch
from
August 26, 2026 00:44
ce23b5b to
0816c97
Compare
Contributor
Author
|
Thanks for kicking off the CI @alexanderankin - that one was on me. The uv.lock didn't have the new toxiproxy extra, so uv sync couldn't find it. I've regenerated the lock and pushed, so it should be good to go on another run whenever you get a chance. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1105 +/- ##
=======================================
Coverage 86.15% 86.15%
=======================================
Files 16 16
Lines 1769 1769
Branches 198 198
=======================================
Hits 1524 1524
Misses 185 185
Partials 60 60 🚀 New features to boost your workflow:
|
alexanderankin
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Container
Fixes #1104
Adds a
ToxiproxyContainer(testcontainers.community.toxiproxy) that wraps Toxiproxy for simulating adverse network conditions — latency, bandwidth limits, connection drops and more — in integration tests. Toxiproxy modules already exist for testcontainers Java, Go and .NET; this brings the same to Python.What it does
ToxiproxyContainerexposes the HTTP control API (8474) and a range of proxy ports, and waits on the control API before it's ready.create_proxy(name, upstream)routes traffic to an upstream (e.g."nginx:80"of a container that shares a network) and returns aToxiproxyProxywhosehost/proxy_portyou connect through.ToxiproxyProxy.add_toxic(...)injects toxics via the control API.urllib.Usage
The included integration test starts nginx behind Toxiproxy, verifies traffic flows through the proxy, then injects a latency toxic and asserts the response is delayed.
PR Checklist
fix(toxiproxy):as recommended for community modules.src/testcontainers/community/toxiproxy/testcontainers.community.toxiproxy.*.tests/community/toxiproxy/.docs/community/toxiproxy.rstwith the.. autoclassand.. titledirectives.__init__.pywith corresponding tests. Docs page + example added underdocs/modules/and the nav entry inmkdocs.yml.pyproject.tomlunderproject.optional-dependenciesastoxiproxy = [](no extra dependencies).